﻿
#include "CDispatch.h"
#include <functional>

CDispatch::CDispatch(void) : m_status(false)
{
}

CDispatch::~CDispatch(void)
{
}

bool CDispatch::start(void)
{
    if (!m_status)
    {
        if (init() < 1)
            return false;
        m_status = true;
        m_th = std::thread(std::bind(&CDispatch::run, this));
        m_th.detach();      //线程后台运行
    }
    return m_status;
}

bool CDispatch::stop(void)
{
    if (m_status)
    {
        m_status = false;
        free();
    }
    return m_status;
}

//int CDispatch::init(void)
//{
//    return 1;
//}
//
//int CDispatch::free(void)
//{
//    return 1;
//}
//
//int CDispatch::runHelp(void)
//{
//    return 1;
//}

void CDispatch::run()
{
    runHelp();
    //while (m_status)
    //{
    //    runHelp();
    //    //SLEEP(1000);
    //    //SLEEP(1);
    //}
    //free();
    m_status = false;
}

bool CDispatch::getstatus(void)
{
    return m_status;
}






